package com.example.innovate.service.impl;

import com.example.innovate.domain.NewFieldDO;
import com.example.innovate.domain.NewFieldDOExample;
import com.example.innovate.mapper.NewFieldDOMapper;
import com.example.innovate.service.NewFieldService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class NewFieldServiceImpl implements NewFieldService {
    @Autowired
    NewFieldDOMapper newFieldDOMapper;

    @Override
    public void addField(NewFieldDO newFieldDO) {
        newFieldDOMapper.insertSelective(newFieldDO);
    }

    @Override
    public void deleteField(int id) {
        newFieldDOMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<NewFieldDO> getFieldBySurface(String surface) {
        NewFieldDOExample newFieldDOExample = new NewFieldDOExample();
        newFieldDOExample.createCriteria()
                .andFieldSurfaceEqualTo(surface);
        return newFieldDOMapper.selectByExample(newFieldDOExample);
    }

    @Override
    public void updateField(NewFieldDO newFieldDO) {
        newFieldDOMapper.updateByPrimaryKeySelective(newFieldDO);

    }
}
